﻿/*
   Author: Tomer Paz
   BOGO.com
   2009
*/

/* Message box template */

package monopoly.GameController.Dialogs.Templates {
	
	import fl.controls.Label;
	import fl.containers.ScrollPane;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import flash.events.Event;
	
	public class MessageBox extends ScrollPane 
		{
		protected var _label:Label;
		
		protected var _defaultWidth = 200;
		protected var _defaultHeight = 100;
		protected var _defaultX		= 0;
		protected var _defaultY		= 0;
		
		public function MessageBox(Title:String)
			{
			with (this)
				{
				setSize(_defaultWidth, _defaultHeight);
				alpha = 1;
				}

			setupLabel(Title);
			}

		protected function setupLabel(Title:String):void
			{
			_label = new Label();
			
			_label.textField.autoSize = TextFieldAutoSize.LEFT;
			_label.visible = true;
			
			addChild(_label);
            _label.move(22, 23);
			_label.text = Title;
			}
		public function set Text(Title:String):void
			{
			this._label.text = Title;
			}
			
		/* to be called by the Game Controller once box can be removed */
		
		public function remove( ):void
			{
			removeChild(_label);
			}
			
		private function onPaneResize(e:Event):void
			{
			_label.drawNow();
			}
		}
}